<template>
    <el-row type="flex" justify="space-around" align="middle" style="height:40px;width:100%;" >
        <el-col>
          <span>{{data.name}}</span>
        </el-col>
        <el-col :span="4">
          <el-row type="flex">
            <el-col>
              <span>{{data.manager}}</span>
            </el-col>
            <el-col>
              <el-dropdown @command="handleCommand">
                <span>
                  <button>修改</button>
                   <button>删除</button>
                </span>
               
              </el-dropdown>
            </el-col>
          </el-row>
        </el-col>
      </el-row>

</template>

<script>
import {remove} from '../../api/base/menus'
export default {
    name: 'adada',

   props: {
     data: {
        type: Object,
        default: () => ({})
     },
     isRoot: {
        type:Boolean,
        default: true
     }
   },


    data() {
        return {
            
        };
    },

    mounted() {
        
    },

    methods: {
        handleCommand(type){
            if (type === 'add'){
                this.$emit('openDialog',this.data)
            }else if(type === 'del'){
             // 删除接口
             // 当前这个节点的ID this.data.id
             this.$confirm('确认删除吗' ,'提示' , {
              type:'warning'
             }).then(async res => {
             await remove(this.data.id)
             }).then(res =>{
              this.$message.success("部门删除成功")
              // 刷新列表 $emit/$on
              this.$emit('refreshList')
             })
              
            }else{
              // 编辑
              this.$emit('openDialog',this.data,type)
            }
        }
    },
};
</script>

<style lang="scss" scoped>

</style>